<?php
require_once '../config/config.php';
require_once 'inc/session.php';

$menu = 21;

if (isset($_POST['submit'])) {
    foreach ($_POST as $key => $val)
        $_POST[$key] = mysql_real_escape_string($val);

    $sql = 'UPDATE texte_qui_somme_nous SET texte = "' . $_POST["presentation"] . '" WHERE id = 1';
    $req = mysql_query($sql) or die(mysql_error());

    $message_succes = 'Mise à jour effectuée avec succès.';
}

$sql = 'SELECT texte FROM texte_qui_somme_nous WHERE id = 1';
$req = mysql_query($sql) or die(mysql_error());
$res = mysql_fetch_array($req);


foreach ($res as $key => $val)
    $res[$key] = stripslashes($val);

$presentation = $res['texte'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Interface Administration | L'essentiel du sup</title>
        <link rel="shortcut icon" href="images/favicon.ico" />
        <link rel="stylesheet" href="css/style.css" type="text/css" />
        <link rel="stylesheet" href="css/plugins/jquery.wysiwyg.css" type="text/css" />
        <!--[if IE 9]>
            <link rel="stylesheet" media="screen" href="css/ie9.css"/>
        <![endif]-->
        <!--[if IE 8]>
            <link rel="stylesheet" media="screen" href="css/ie8.css"/>
        <![endif]-->
        <!--[if IE 7]>
            <link rel="stylesheet" media="screen" href="css/ie7.css"/>
        <![endif]-->
        <script type="text/javascript" src="js/plugins/jquery-1.7.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery.flot.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery.flot.resize.min.js"></script>
        <script type="text/javascript" src="js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
        <script type="text/javascript" src="js/custom/general.js"></script>
        <script type="text/javascript" src="js/plugins/wysiwyg/jquery.wysiwyg.js"></script>
        <script type="text/javascript" src="js/plugins/wysiwyg/wysiwyg.image.js"></script>
        <script type="text/javascript" src="js/plugins/wysiwyg/wysiwyg.link.js"></script>
        <script type="text/javascript" src="js/plugins/wysiwyg/wysiwyg.table.js"></script>
        <script type="text/javascript" src="js/plugins/wysiwyg/wysiwyg.i18n.js"></script>
        <script type="text/javascript" src="js/plugins/wysiwyg/i18n/lang.fr.js"></script>
        <script type="text/javascript">
            jQuery(document).ready(function() {
                jQuery('#wysiwyg').wysiwyg({
                    controls: {
                        cut: {visible: true},
                        copy: {visible: true},
                        paste: {visible: true},
                        paragraph: {visible: true},
                        increaseFontSize: {visible: true},
                        decreaseFontSize: {visible: true},
                        insertHorizontalRule: {visible: true},
                        code: {visible: false},
                        insertImage: {visible: false}
                    },
                    plugins: {
                        autoload: true,
                        i18n: {lang: "fr"}
                    }
                });
            });
        </script>
        <!--[if lt IE 9]>
                <script src="js/css3-mediaqueries.js"></script>
        <![endif]-->
    </head>
    <body class="loggedin">
        <?php include('inc/header.php') ?>
        <div class="mainwrapper">
            <div class="mainwrapperinner">
                <?php include('inc/menu.php') ?>
                <div class="maincontent noright">
                    <div class="maincontentinner">
                        <ul class="maintabmenu">
                            <li class="current">
                                <a>Gestion des textes</a>
                            </li>
                        </ul>
                        <div class="content">
                            <?php if (!empty($message_succes)) {
                                ?>
                                <div class="notification msgsuccess">
                                    <a class="close"></a>
                                    <p><?php echo $message_succes; ?></p>
                                </div>
                            <?php } ?>
                            <?php if (!empty($message_erreur)) {
                                ?>
                                <div class="notification msgerror">
                                    <a class="close"></a>
                                    <p><?php echo $message_erreur ?></p>
                                </div>
                            <?php } ?>
                            <form id="validate" class="stdform stdform2" action="" method="post">
                                <p>
                                    <label>Qui sommes nous ?</label>
                                    <span class="field">
                                        <textarea id="wysiwyg" name="presentation" cols="1" rows="15"><?php echo $presentation ?></textarea> 
                                    </span>
                                </p>
                                <p class="stdformbutton">
                                    <button name="submit" class="submit radius2">Enregistrer</button>
                                    <input type="reset" class="reset radius2" value="Annuler" />
                                </p>
                            </form>
                            <br clear="all" />
                        </div>
                    </div>
                    <div class="footer">
                        <p></p>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
